import xlrd
from ChatbotWithRetrieval import ChatbotWithRetrieval

# 打开文件
data = xlrd.open_workbook(r'D:\浏览器下载\极氪知识库.xlsx')

vlanSheet1 = data.sheet_by_index(0)

vlanNrows = vlanSheet1.nrows

llm = ChatbotWithRetrieval("zeekr_vectors.faiss")
faiss = llm.store
for r in range(1, vlanNrows):
    question = vlanSheet1.cell(r, 0).value
    answer = vlanSheet1.cell(r, 1).value
    category = vlanSheet1.cell(r, 2).value
    template = f"""分类 : {category} ; 问题：{question} ; 答案：{answer} """
    print(template)
    faiss.write_templates(template)
